﻿@{
    ViewBag.Title = "Activity History";
}

@using ICDA.Web.Helper;
@{DatetTimeHelper dt = new DatetTimeHelper();}

<div id="myDiv" style="width: 100%; height:100%; margin-left:100px; z-index:10;">
        <table id="activityHistoryGrid" cellpadding="0" cellspacing="0" style="min-height:300px;"> </table>
        <div id="activityGridpager" style="text-align: center;"> </div>
</div>
<script type="text/javascript" language="javascript">
    $.lastSelectedRow = null;
    function checkTimeSpend(value, colname) {
        if (value < 0 || value > 10)
            return [false, "Please enter value of " + colname + " between 0 and 10 otherwise fill remaining hours in overtime"];
        else
            return [true, ""];
    }
    function checkOverTime(value, colname) {
        if (value < 0 || value > 10)
            return [false, "You are not allowed to fill overtime more than 10 hours "];
        else
            return [true, ""];
    }
    function checkDateTime(value, colname) {
        var startDay = 0;
        var weekStart = new Date(today.getDate() - (7 + today.getDay() - startDay) % 7);
        var weekEnd = new Date(today.getDate() + (7 - today.getDay() - startDay) % 7);
    }
    $(document).ready(function () {
        jQuery("#activityHistoryGrid").jqGrid({
            url: '@Url.Action("GetHistoricalRecords")',
            datatype: "json",
            mtype: 'POST',
            height: 'auto',
            editurl: '@Url.Action("UpdateTask")',
            colNames: ['ID', 'Name','Task', 'ActivityDate', 'TimeSpend', 'OverTime'],
            colModel: [
                        { name: 'ID', index: 'ID', width: 50 },
                        { name: 'Name', index: 'Name', width: 120 },
                        { name: 'Task', index: 'Task', width: 120, editable: true},
                        { name: 'ActivityDate', index: 'ActivityDate', width: 120, align: "left",
                            editable: true,
                            formatter: 'date',
                            formatoptions: { srcformat: 'ISO8601Short', newformat: 'd-M-y' },
                            editoptions: { size: 20, dataInit: function (el) { $(el).datepicker({ dateFormat: 'mm-dd-yy' }); }
                            }
                        },
   		                { name: 'TimeSpend', index: 'TimeSpend', width: 120, editable: true,summaryTpl:'<b>{0} Hour(s)</b>', summaryType: 'sum'},
   		                { name: 'OverTime', index: 'OverTime', width: 120, align: "left", editable: true,summaryTpl:'<b>{0} Hour(s)</b>', summaryType: 'sum'}
   	                  ],
            pager: '#activityGridpager',
            sortname: 'ActivityDate',
            imgpath: '/Content/themes/base/images',
            viewrecords: true,
            sortorder: "desc",
            grouping:true,
            groupingView : {
                groupField: ['ActivityDate'],
                groupSummary : [true],
   		        groupColumnShow : [true],
   		        groupText : ['<b>{0}</b>'],
   		        groupCollapse : false,
		        groupOrder: ['asc']
   	        },
             loadComplete: function () {
                $(".ui-jqgrid tr.jqfoot td").css("background", "#F3F3F3");
            },
   	        caption: "My Historical Activity Records",

            viewrecords: true
        });
         $('.jqgfirstrow').hide();
    });
   
</script>